import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.Map;

public class LinkedHashMapTest {
    public static void main(String[] args) {
        HashMap<Integer,String> hashMap = new HashMap<Integer,String>();

        hashMap.put(1,"aaa");
        hashMap.put(6,"bbb");
        hashMap.put(3,"ccc");
        hashMap.put(2,"ddd");
        hashMap.put(5,"eee");

        Iterator<Map.Entry<Integer,String>> it = hashMap.entrySet().iterator();

        while (it.hasNext()){
            Map.Entry<Integer,String> me = it.next();
            Integer key = me.getKey();
            String value = me.getValue();

            System.out.println(key+":"+value);
        }

        System.out.println("--------------------------------------------");

        showLinkedHashMap();
    }

    private static void showLinkedHashMap() {
        LinkedHashMap<Integer,String> linkedHashMap = new LinkedHashMap<Integer,String>();

        linkedHashMap.put(1,"aaa");
        linkedHashMap.put(6,"bbb");
        linkedHashMap.put(3,"ccc");
        linkedHashMap.put(2,"ddd");
        linkedHashMap.put(5,"eee");

        Iterator<Map.Entry<Integer,String>> it = linkedHashMap.entrySet().iterator();

        while (it.hasNext()){
            Map.Entry<Integer,String> me = it.next();
            Integer key = me.getKey();
            String value = me.getValue();

            System.out.println(key+":"+value);
        }
    }
}
